package com.gamehouse.eggpoacher;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class myScores extends Activity{
	
	public ListView viewscores;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN );
		setContentView(R.layout.scores);
		
		 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1);
		 viewscores = (ListView)findViewById(R.id.viewscores);
			
		 DataBaseAdapter db = new DataBaseAdapter(this);
		 db.open();
		 Cursor c = db.getTop5Scores();
		 int position = 1;
	        if (c.moveToFirst())
	        {
	        	do {  
	        		if (position == 6){
						 break;
					 }
	        		System.out.println(c.getString(0) + "-" + c.getInt(1) );
	        		adapter.add(position + " - " + c.getString(0) + " , " + c.getInt(1) );
	        		position ++;
	        	} while (c.moveToNext());
	        	}
	     c.close();
         db.close();
		 viewscores.setAdapter(adapter);
		}
	
	public void mostrarMenu(View view){
		//Intent myIntent = new Intent(view.getContext(), myMenu.class);
		//startActivityForResult(myIntent, 0);
		finish();
	}
}